import Rx from "rxjs"

var observable = Rx.Observable.create(observer=>{
    let i=0;
    setInterval(()=>{
        console.log("observable running");
        observer.next(i++);
    },1000);
});
var subscription = observable.subscribe(x => console.log(x));

setTimeout(() => {
  subscription.unsubscribe();//取消注册在上面的监听，但是要注意，这个并不会影响observable的运行
}, 3100)